<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>


<title>POS收单运营管理平台</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link href="<s:url value="/css/common.less"/>" type="text/less"
	rel="stylesheet" />
	<link href="<s:url value="/css/common.css"/>" type="text/css"
	rel="stylesheet" />

<script type="text/javascript"
	src="<s:url value="/js/jquery-1.3.2.js" />"></script>
<script type="text/javascript"
	src="<s:url value="/js/jquery-1.9.1.js" />"></script>
<script type="text/javascript"
	src="<s:url value="/js/jquery.blockUI.js" />"></script>
<script type="text/javascript"
	src="<s:url value="/js/jquery.validate.min.js" />"></script>
<script type="text/javascript"
	src="<s:url value="/js/pwms.validate.js?v13" />"></script>
<script language="javascript" type="text/javascript"
	src="<s:url value="/js/My97DatePicker/WdatePicker.js"/>"></script>

<style type="text/css">

.error {
	color: red;
}

</style>
<script type="text/javascript">

	$(document).ready(function() {
		//检查是什么状态，更新或新增
		var flag="${flag}";
		if(flag=="update"){
			$("#switchsForm").attr("action","<%=basePath%>/switchs/updateMchtSwitch.ct");
		}

		// 字符最大长度验证（一个中文字符长度为2）
		jQuery.validator.addMethod("stringMaxLength", function(value,element, param) {
			var length = value.length;
			for ( var i = 0; i < value.length; i++) {
				if (value.charCodeAt(i) > 127) {
					length++;
				}
			}
			return this.optional(element) || (length <=param);
		}, $.validator.format("长度不能大于{0}!"));
		jQuery.validator.addMethod("dateValidate",function(value,element){
			var min=$("#beginDate").val();
			var max=$("#endDate").val();
			
			if(max<min){
				return this.optional(element) || false;
			}
			return this.optional(element) || true;
		},"结束时间不能小于开始时间");
		$("#switchsForm").validate({
			debug : true,
			submitHandler : function(form) {
				$("#btnAdd").attr("disabled",true);
					form.submit();
			},
			rules : {
				"bean.transCd":{required : true},
				"bean.mchtCd":{required : true},
				"bean.begin" : {required : true},
				"bean.end" : {required : true,dateValidate:true},
				"bean.flag" : {required : true}
			},
			messages : {
				"bean.transCd":{required : "必选"},
				"bean.mchtCd":{required : "必填"},
				"bean.begin" : {required : "必填"},
				"bean.end" : {required : "必填"},
				"bean.flag" : {required : "必选"}
			},errorPlacement: function(error, element) { 
			    if ( element.is(":radio") ) 
			        error.appendTo ( element.parent() ); 
			    else if ( element.is(":checkbox") ) 
			        error.appendTo ( element.parent() ); 
			    else if ( element.is("input") ) {
			    	error.appendTo ( element.parent() ); 
			    }
			    else 
			        error.insertAfter(element); 
			} 

		});
		
	});

</script>



</head>

<body>
			<s:form id="switchsForm" action="/switchs/saveSwitch.ct" method="post"  theme="simple"  >
				<table width="100%" class="tb" >
			        <tr class="tb-line">
			            <td class="tb-td" colspan="6">
				            <div class="tb-h2">POS收单运营管理平台</div>
					   	</td>
			        </tr>
	                <tr class="tb-line bg-gray">
			            <td class="tb-td" colspan="4"><div class="tb-h3">
			            <s:if test="#request.flag ==\"update\"">
			                	修改D0交易控制(针对商户)
			               </s:if>
			               <s:else>
			               		添加D0交易控制(针对商户)
			               </s:else>
			                	</div>
			        </tr>
			        <tr class="tb-line">
				    						     
				    	<td width="12%" align="right" class="tb-td">
				    	<div class="tb-h4" id="title">交易名称：</div>
				    	</td>
				    	<td class="tb-td" width="35%">
				    	<s:if test="#request.flag ==\"update\"">
				    		<s:if test="bean.transCd == \"1171\" ">
						    T+0 实时收款 
							</s:if>
							<s:elseif test="bean.transCd == \"1011\" ">
							消费
							</s:elseif>
				    	</s:if>
				    	<s:else>
				    	<label class="tb-select">
							<s:select name="bean.transCd" list="#{'1171':'T+0 实时收款','1011':'消费'}" headerKey="" headerValue="不限" cssClass="queryWidth" id="changeType"/>
				    	</label>
				    	<font color="red">*</font>
				    	</s:else>		    	
				    	</td>
				    	<td width="12%" align="right" class="tb-td">
				    	<div class="tb-h4">所属机构：</div> </td>
				    	<td class="tb-td">
				    	<label class="tb-select">
				    	<s:if test="#request.flag ==\"update\"">
				    	<s:select cssClass="queryWidth" name="bean.insCd" id="orgCode"
							list="#request.orgList" listKey="insIdCd" listValue="insName" disabled="true"/>
				    	</s:if>
				    	<s:else>
				    	<s:select cssClass="queryWidth" name="bean.insCd" id="orgCode"
							list="#request.orgList" listKey="insIdCd" listValue="insName" />
				    	</s:else>
				    	<font color="red">*</font>				 		 
                		</label>
				    	</td>
				    	</tr>
					<tr class="tb-line">
				    						     
				    	<td width="12%" align="right" class="tb-td">
				        	<div class="tb-h4" id="title">商户号：</div>
			            </td>
			            <td class="tb-td" width="35%">
			            
			            		<s:if test="#request.flag ==\"update\"">
			            		<label class="tb-input-lengthen">
			            		<s:textfield maxLength="200" name="bean.mchtCd"
									cssClass="queryWidth" id="mchtId" disabled="true"></s:textfield>
									</label>
									<s:hidden name="bean.mchtCd"></s:hidden>
									<s:hidden name="bean.insCd"></s:hidden>
									<s:hidden name="bean.transCd"></s:hidden>
			            		</s:if>	
			            		<s:else>
			            		<label class="tb-input-lengthen">
			            		<s:textfield maxLength="200" name="bean.mchtCd"
									cssClass="queryWidth" id="mchtId"></s:textfield>
									</label>
									<font color="red">*</font>
			            		</s:else>
																
						</td>
						<td align="right" class="tb-td">
				        		<div class="tb-h4">状态：</div>
			            </td>
			            <td class="tb-td" >
			             		<s:radio name="bean.flag" list="#{'1':'开启','0':'关闭' }"></s:radio><font color="red">*</font>
						 </td>
						</tr>
		   				<tr class="tb-line">
				    						     
				    	<td width="12%" align="right" class="tb-td">
				        	<div class="tb-h4" id="title">交易开始时间：</div>
			            </td>
			            <td class="tb-td" width="35%">
			             <label class="tb-input-mini">		             	
								<s:textfield id="beginDate" name="bean.begin" onFocus="WdatePicker({dateFmt:'HHmmss',readOnly:true,wdate:true,errDealMode:0});"
							theme="simple" cssClass="queryWidth"/>
							</label>
							<font color="red">*</font>
						</td>
						<td align="right" class="tb-td" width="">
				        		<div class="tb-h4">交易开结束时间：</div>
			            </td>
			            <td class="tb-td" >
			             <label class="tb-input-mini">
			             		<s:textfield id="endDate" name="bean.end" onFocus="WdatePicker({dateFmt:'HHmmss',readOnly:true,wdate:true,errDealMode:0});"
							theme="simple" cssClass="queryWidth" />
							</label>
							<font color="red">*</font>
						 </td>
						</tr>
						
				</table>		
		      <table width="100%" border="0" cellspacing="0" class="table">
		           	<tr class="tb-line">
						<td colspan="4" align="center"><span style="color: red"><s:actionerror /></span>
							<span style="color: red;"><s:actionmessage /></span > <span style="color: red;"><s:fielderror
									cssClass="fieldError" /></span>
							<span id="otherError"></span>
						</td>
					</tr>
					<tr class="tb-line">
			            <td class="tb-td line-submit" align="center" colspan="4">
			                <label class="tb-input-submit">		                
			                	<s:submit id="btnAdd" value="保  存" />								
							</label>
			                <label class="tb-input-submit">
								<input type="reset" value="取  消"/>
							</label>
							<label class="tb-input-submit">
								<input type="button" value="返回" onclick="history.back()"/>
							</label>
						</td>
					</tr>
            </table>
			</s:form>	
</body>
</html>
